<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ws测试</title>
</head>
<body>

<script type="text/javascript">
    var socket = new WebSocket("ws://localhost:8093/ws?ss=1s");

    socket.onopen = function (event) {
        let data = {
            eventType: "initRoom",
            data: {
                userId: 1120
            }
        }
        setTimeout(function () {
            socket.send(JSON.stringify(data))
        }, 5000)
    };
    // 监听消息事件 服务器发的消息都在这里
    socket.onmessage = function (event) {
        let data = JSON.parse(event.data)
        console.log(data);
    };

    socket.onclose = function (event) {

    }
</script>
</body>
</html>
